package face.pay.web.mch.store;

import face.pay.system.annotation.CurrentUser;
import face.pay.common.enterprise.service.IStoreInfoBaseService;
import face.pay.common.enterprise.service.IterminalBaseService;
import face.pay.entity.StoreInfo;
import face.pay.entity.TerminalInfo;
import face.pay.entity.UserInfo;
import face.pay.util.ResultMessage;
import face.pay.util.page.PageData;
import face.pay.util.page.PageParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/store")
public class StoreController {

    @Autowired
    private IStoreInfoBaseService iStoreInfoBaseService;

    @Autowired
    private IterminalBaseService iTerminalBaseService;

    @RequestMapping(value = "/storemanage")
    public String storeManage(@CurrentUser UserInfo loginUser){
        return "store/storemanage";
    }

    @RequestMapping("/queryData")
    @ResponseBody
    public PageData data(PageParam pageParam, StoreInfo storeInfo, @CurrentUser UserInfo userInfo) throws Exception {

        storeInfo.setUserId(userInfo.getId());
        return  this.iStoreInfoBaseService.queryPage(storeInfo,pageParam);
    }

    @RequestMapping( "/storeterminalinfo")
    public String storeInfo(Model model,TerminalInfo terminalInfo, @CurrentUser UserInfo userInfo){

        terminalInfo.setStoreId(null);
        ResultMessage resultMessage =this.iTerminalBaseService.getNoBing(model,terminalInfo,userInfo);
        return "store/storeterminalinfo";
    }

}
